package com.yhm.testSpringMvc.myAnotation;

import org.springframework.util.CollectionUtils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Arrays;

public class MainTest {
    public static void main(String[] args) {


        MyAnotationTest myAnotationTest = new MyAnotationTest();
        myAnotationTest.setName("abc" +
                "");

        Class c = null;
        try {
            c = Class.forName("com.yhm.testSpringMvc.myAnotation.MyAnotationTest");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        boolean is = c.isAnnotationPresent(YhmLogAnotation.class);
        if (is) {
            YhmLogAnotation yhmLogAnotation = (YhmLogAnotation) c.getAnnotation(YhmLogAnotation.class);
            System.out.println(yhmLogAnotation.desc());
            System.out.println(yhmLogAnotation.logMethod());
            System.out.println(yhmLogAnotation.privator());
            System.out.println();

        }

        Method[] method = c.getMethods();
        if (method != null && method.length > 0) {
            for (Method method1 : method) {
                boolean isYhmLogAnotionFlag = method1.isAnnotationPresent(YhmLogAnotation.class);
                if (isYhmLogAnotionFlag) {
                    YhmLogAnotation yhmLogAnotation = method1.getAnnotation(YhmLogAnotation.class);
                    System.out.println(yhmLogAnotation.desc());
                    System.out.println(yhmLogAnotation.logMethod());
                    System.out.println(yhmLogAnotation.privator());
                    System.out.println();
                }
            }
        }


        Constructor<MyAnotationTest>[] constructors = c.getConstructors();
        if (constructors != null && constructors.length > 0) {
            for (Constructor constructor : constructors) {
                boolean isYhmLogAnotionFlag = constructor.isAnnotationPresent(YhmLogAnotation.class);
                if (isYhmLogAnotionFlag) {
                    YhmLogAnotation yhmLogAnotation = (YhmLogAnotation) constructor.getAnnotation(YhmLogAnotation.class);
                    System.out.println(yhmLogAnotation.desc());
                    System.out.println(yhmLogAnotation.logMethod());
                    System.out.println(yhmLogAnotation.privator());
                    System.out.println();
                }
            }
        }

    }
}
